Running the application

First, in the server.py you have the following code:

  1. 1
  2. 2
  1. if __name__ == "__main__":
  2. app.run(debug=True, port=8000, host='0.0.0.0')

The line if __name__ == "__main__": checks if the script is being run directly. If so, it starts the Flask application with app.run(debug=True, port=8000, host='0.0.0.0'). This starts a web server that listens on port 8000 and is accessible from any IP address ('0.0.0.0'). The server runs in debug mode (debug=True), which provides detailed error messages and automatically reloads the server when code changes.

Creating the Docker container

Docker allows for the creation of “containers” that package an application and its dependencies together. This allows the application to run consistently across different environments, as the container includes everything it needs to run. Additionally, using a Docker image to create and run applications can simplify the deployment process, as the image can be easily distributed and run on any machine that has Docker. This easy distribution of image ensures that the application runs in the same way in development, testing, and production environments.

The git clone from the second page already comes with a Dockerfile and requirements.txt for this application. These files are used to build the image with the dependencies already installed. Looking into the Dockerfile you can see it is fairly simple, it just creates a Python environment, moves all the files from the local directory to the container, installs the required packages, and then starts the application by running the python command.

There are 3 different containers that need to run simultaneously for the application to run and interact with Text-to-Speech and Speech-to-Text capabilities.

Starting the application

This image is quick to build as the application is quite small. These commands first build the application running the commands in the Dockerfile and provide a tag or name to the built container as build-your-own-chatbot, then run it in the foreground on port 8000. You'll need to run these commands every time you wish to make a new change to one of the files.

  1. 1
  2. 2
  1. docker build . -t build_chatbot_for_your_data
  2. docker run -p 8000:8000 build_chatbot_for_your_data

The application must be opened in a new tab since the minibrowser in this environment does not support certain required features.

Your browser may deny “pop-ups” but please allow them for the new tab to open up.

At this point, the application will run but return null for any input.

Once you've had a chance to run and play around with the application, please press Crtl (a.k.a. control (^) for Mac) and C at the same time to stop the container and continue the project.

The application will only run while the container is up. If you make new changes to the files and would like to test them, you will have to rebuild the image.